Repository navigation
fix(store): a resource create never moves a live resource to another project or org - #2000
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 Summary
Merge Risk: 🟡 Moderate · up to
|
Coverage Report for CI Build 38872869111Coverage increased (+0.003%) to 54.962%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
rohilsurana
left a comment
There was a problem hiding this comment.
The WHERE on the conflict update is the right tool. No row back means no move, and the service stops before SpiceDB. Approving, with one optional ask inline.
…project or org The URN upsert updates an existing live row only when it belongs to the same project, or to no project for an organization resource. Otherwise Create returns ErrConflict, so a create can no longer take over another project's or organization's row.
b5ccc83 to
0e1de17
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository: raystack/frontier/.coderabbit.yaml
- Review profile: CHILL
- Plan: Advanced
- Run ID:
35c37b3e-29f0-4cc1-aca6-025eb1e55963
📒 Files selected for processing: 2
internal/store/postgres/resource_repository.gointernal/store/postgres/resource_repository_test.go
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.
Summary
A resource create no longer moves a live resource to another project or organization. Stacked on #1985.
Changes
ResourceRepository.Createupdates the existing live row only when it has the sameproject_id, compared withIS NOT DISTINCT FROMso two organization resources, both without a project, still match. Otherwise no row comes back andCreatereturnsErrConflict, which the handlers answer with already exists.Technical Details
project_idforeign key has no delete action.Test Plan
go test ./internal/store/postgres/passes. NewTestCreatecases: an organization resource re-created with the same URN updates in place; the URN of another project's live resource returns conflict and the row keeps its project; a project resource and an organization resource sharing a URN return conflict both ways.Where, the two conflict cases fail. With=in place ofIS NOT DISTINCT FROM, the organization re-create case fails.go test ./test/e2e/...passes.golangci-lint runreports no issues.SQL Safety
goqu.Lin the conflict update takes twogoqu.Iidentifiers and no values.ToSQL()callers capture and forward params (query, params, err := stmt.ToSQL(); db.…Context(ctx, …, query, params...)). Neverquery, _, err := ….?placeholders inside single-quoted SQL literals ingoqu.L.//nolint:forbidigoor// #nosec G20xannotations.